
//
//  ActivityDetailView.m
//  UI-豆瓣项目APP
//
//  Created by dllo on 15/9/9.
//  Copyright (c) 2015年 孙鹏. All rights reserved.
//

#import "ActivityDetailView.h"
#import "UIImageView+WebCache.h"
@implementation ActivityDetailView
-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if(self){
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews{
    self.title = [[UILabel alloc]initWithFrame:CGRectMake(25, 10, 200, 30)];
    self.title.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.title];
    [_title release];
    
    self.title1 = [[UILabel alloc]initWithFrame:CGRectMake(155, 50, 225, 20)];
    self.title1.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.title1];
    [_title1 release];
    
    self.title2 = [[UILabel alloc]initWithFrame:CGRectMake(160, 75, 180, 20)];
    self.title2.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.title2];
    [_title2 release];
    
    self.title3 = [[UILabel alloc]initWithFrame:CGRectMake(160, 100, 180, 20)];
    self.title3.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.title3];
    [_title3 release];
    
    self.title4 = [[UILabel alloc]initWithFrame:CGRectMake(160, 125, 200, 80)];
    self.title4.backgroundColor = [UIColor whiteColor];
    self.title4.numberOfLines = 0;
    [self addSubview:self.title4];
    [_title4 release];
    
    self.detaile_Image = [[UIImageView alloc]initWithFrame:CGRectMake( 25, 50, 100, 140)];
    self.detaile_Image.backgroundColor = [UIColor redColor];
    [self addSubview:self.detaile_Image];
    [_detaile_Image release];
    
    self.detaile_Image1 = [[UIImageView alloc]initWithFrame:CGRectMake( 130, 50, 20, 20)];
    self.detaile_Image1.image = [UIImage imageNamed:@"icon_date_blue"];
    [self addSubview:self.detaile_Image1];
    [_detaile_Image1 release];
    
    self.detaile_Image2 = [[UIImageView alloc]initWithFrame:CGRectMake( 130, 75, 20, 20)];
     self.detaile_Image2.image = [UIImage imageNamed:@"icon_sponsor_blue"];
    [self addSubview:self.detaile_Image2];
    [_detaile_Image2 release];
    
    self.detaile_Image3 = [[UIImageView alloc]initWithFrame:CGRectMake( 130, 100, 20, 20)];
    self.detaile_Image3.image = [UIImage imageNamed:@"icon_catalog_blue"];
    [self addSubview:self.detaile_Image3];
    [_detaile_Image3 release];
    
    self.detaile_Image4 = [[UIImageView alloc]initWithFrame:CGRectMake( 130, 135, 20, 20)];
    self.detaile_Image4.image = [UIImage imageNamed:@"icon_spot_blue"];
    [self addSubview:self.detaile_Image4];
    [_detaile_Image4 release];
    
    self.BigTitle =[[UILabel alloc]initWithFrame:CGRectMake(25, 200, 350, 30)];
    self.BigTitle.text = @"活动介绍";
    self.BigTitle.textAlignment = NSTextAlignmentLeft;
    self.BigTitle.font = [UIFont systemFontOfSize:22];
    [self addSubview:self.BigTitle];
    [_BigTitle release];
    
    self.content = [[UILabel alloc]initWithFrame:CGRectMake(25,240,330,5000)];
    self.content.textAlignment = NSTextAlignmentLeft;
    
    self.content.font = [UIFont systemFontOfSize:15];
    self.content.numberOfLines = 0;
    [self addSubview:self.content];
    [_content release];
}
-(void)setActivityV:(Activitylist *)activityV{
    if(_activityV != activityV){
        [_activityV release];
        _activityV = [activityV retain];
    }
    NSString *start = [activityV.begin_time substringWithRange:NSMakeRange(5, 11)];
    NSString *end = [activityV.end_time substringWithRange:NSMakeRange(5, 11)];
    NSString*data = [NSString stringWithFormat:@"%@--%@",start,end];
    self.title.text = activityV.title;
    self.title1.text = data;
    self.title2.text = activityV.act.name;
    self.title3.text = activityV.category_name;
    self.title4.text = activityV.address;
    self.content.text =  activityV.content;
    NSURL *urlStr = [NSURL URLWithString:self.activityV.image];
    [self.detaile_Image sd_setImageWithURL:urlStr placeholderImage:[UIImage imageNamed:@"placehold"]];
//    要先有文字才能使用自适应高度
    [self.content sizeToFit];
//    NSLog(@"content %f",self.content.frame.size.height);
}
-(void)getValueHeight:(heightBlock)height{
    height(self.content.frame.size.height);
}
@end
